package com.shr.xsunmvc.db.mapper;

import java.util.HashMap;
import java.util.Map;

import com.shr.xsunmvc.db.Model;
import com.shr.xsunmvc.db.Table;

/**
 * 将Model类型映射到Table
 * @author sun haoran
 *
 */
public class TableMapper {
	private final Map<Class<? extends Model>, Table> modelToTableMapper = new HashMap<>() ;
	
	private static TableMapper me = new TableMapper(); 
	
	private TableMapper() {}
	
	public static TableMapper me() {
		return me;
	}
	
	public void putTable(Table table){
		modelToTableMapper.put(table.getModelClazz(), table) ;
	}
	
	public Table getTable(Class<? extends Model> clazz){
		return modelToTableMapper.get(clazz) ;
	}
}
